package per.jdz.demo.config;

import com.mybatisflex.core.keygen.IKeyGenerator;
import per.jdz.demo.domain.entity.OriginHouseData;
import per.jdz.demo.utils.Md5Utils;

/**
 * @author Jdz
 * @date 2025/2/5
 */
public class IdGenerator implements IKeyGenerator {
    @Override
    public Object generate(Object entity, String keyColumn) {
        return hashValue((OriginHouseData) entity);
    }

	public String hashValue(OriginHouseData houseData) {
		String projectName = houseData.getProjectName();
		String buildingNumber = houseData.getBuildingNumber();
		String roomNumber = houseData.getRoomNumber();
		String floor = houseData.getFloor();
		String t = projectName + buildingNumber + roomNumber + floor;
        return Md5Utils.hash(t);
	}
}
